package com.ssy.lingxi.purchase.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 商品信息实体类
 * @author wyx
 * @version 2.0.0
 * @date 2021-10-27
 */
@Entity
@Table(schema = "public", name = "pu_purchase_product",
        indexes = {@Index(name = "pu_purchase_product_product_id_idx", columnList = "productId"),
                @Index(name = "pu_purchase_product_product_no_idx", columnList = "productNo"),
                @Index(name = "pu_purchase_product_name_idx", columnList = "name")})
public class PurchaseProduct implements Serializable {
    private static final long serialVersionUID = 4722957765296522906L;

    /**
     * 主键Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "pu_purchase_product_seq")
    @SequenceGenerator(sequenceName = "pu_purchase_product_seq", name = "pu_purchase_product_seq", allocationSize = 1)
    private Long id;

    /**
     * 商品Id（来自商品服务）
     */
    @Column
    private Long productId;

    /**
     * 商品（物料）编号
     */
    @Column(columnDefinition = "varchar(30)")
    private String productNo;

    /**
     * 商品名称
     */
    @Column(columnDefinition = "varchar(100)")
    private String name;

    /**
     * 商品品类
     */
    @Column(columnDefinition = "varchar(50)")
    private String category;

    /**
     * 商品品牌
     */
    @Column(columnDefinition = "varchar(50)")
    private String brand;

    /**
     * 报价商品规格
     */
    @Column(columnDefinition = "varchar(50)")
    private String spec;

    /**
     * 计价单位
     */
    @Column(columnDefinition = "varchar(10)")
    private String unit;

    /**
     * 商品单价（订单价）
     */
    @Column(columnDefinition = "numeric(15,3)")
    private BigDecimal price;

    /**
     * 请购数量
     */
    @Column(columnDefinition = "numeric(15,1)")
    private BigDecimal quantity;

    /**
     * 已转订单数量
     */
    @Column(columnDefinition = "numeric(15,1)")
    private BigDecimal transferQuantity;

    /**
     * 金额
     */
    @Column(columnDefinition = "numeric")
    private BigDecimal amount;

    /**
     * 多对一双向关联订单
     */
    @JsonBackReference
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "purchase_requisition_id")
    private PurchaseRequisition purchaseRequisition;

    /**
     * 物料组
     */
    @Column
    private String goodsGroup;

    /**
     * 生产厂家
     */
    @Column
    private String manuFacturer;

    /**
     * 产地
     */
    @Column
    private String placeOrigin;

    /**
     * 备注
     */
    @Column
    private String remark;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public String getProductNo() {
        return productNo;
    }

    public void setProductNo(String productNo) {
        this.productNo = productNo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getSpec() {
        return spec;
    }

    public void setSpec(String spec) {
        this.spec = spec;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public BigDecimal getQuantity() {
        return quantity;
    }

    public void setQuantity(BigDecimal quantity) {
        this.quantity = quantity;
    }

    public BigDecimal getTransferQuantity() {
        return transferQuantity;
    }

    public void setTransferQuantity(BigDecimal transferQuantity) {
        this.transferQuantity = transferQuantity;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public PurchaseRequisition getPurchaseRequisition() {
        return purchaseRequisition;
    }

    public void setPurchaseRequisition(PurchaseRequisition purchaseRequisition) {
        this.purchaseRequisition = purchaseRequisition;
    }

    public String getGoodsGroup() {
        return goodsGroup;
    }

    public void setGoodsGroup(String goodsGroup) {
        this.goodsGroup = goodsGroup;
    }

    public String getManuFacturer() {
        return manuFacturer;
    }

    public void setManuFacturer(String manuFacturer) {
        this.manuFacturer = manuFacturer;
    }

    public String getPlaceOrigin() {
        return placeOrigin;
    }

    public void setPlaceOrigin(String placeOrigin) {
        this.placeOrigin = placeOrigin;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}
